﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Excel
{
    class UtilityTool
    {
        /**
        * \brief bool至是否值字符串转换
        * 
        * \param[in]  idString 字符串类型的ID值
        * \param[ref]  valid 字符是否可用标识
        */
        public static string BoolToYesOrNoStr(bool boolValue)
        {
            if (boolValue)
            {
                return "是";
            }
            else
            {
                return "否";
            }
        }
        /**
         * \brief Excel列有效性序列
         * 
         * \param[in]  sheet sheet标签页
         * \param[in]  columnIndexString 列标识字符串
         * \param[in]  dataArrayString 单元格有效序列内容字符串
         */
        public static void CellDataArrayForExcel(Microsoft.Office.Interop.Excel.Worksheet sheet, string columnIndexString, string dataArrayString)
        {
            Microsoft.Office.Interop.Excel.Range rng = sheet.Columns[columnIndexString];
            rng.Validation.Add(Microsoft.Office.Interop.Excel.XlDVType.xlValidateList, Microsoft.Office.Interop.Excel.XlDVAlertStyle.xlValidAlertStop,
                Microsoft.Office.Interop.Excel.XlFormatConditionOperator.xlBetween, dataArrayString, Systems.Type.Missing);
            rng.Validation.InCellDropdown = true;
            rng.Validation.IgnoreBlank = true;
        }
    }
}
